{% extends "base.html" %}
{% block content %}
<span class="legend visible-xs-block">{{title}}, 共{{count}}條結果</span>
<div class="visible-xs-block">
        <div class="well">
            排序：
            {% if sort != "title" %}<a href="?sort=title&start={{start}}&name={{name}}">{% endif %}書名{% if sort != "title" %}</a>{% endif%} /
            {% if sort != "pubdate" %}<a href="?sort=pubdate&start={{start}}&name={{name}}">{% endif %}出版{% if sort != "pubdate" %}</a>{% endif%} /
            {% if sort != "rating" %}<a href="?sort=rating&start={{start}}&name={{name}}">{% endif %}評分{% if sort != "rating" %}</a>{% endif%} /
            {% if sort != "timestamp" %}<a href="?sort=timestamp&start={{start}}&name={{name}}">{% endif %}更新{% if sort != "timestamp" %}</a>{% endif%}
        </div>
</div>
<span class="legend hidden-xs">{{title}}, 共{{count}}條結果
        <div class="sorter pull-right">
            排序：
            {% if sort != "title" %}<a href="?sort=title&start={{start}}&name={{name}}">{% endif %}書名{% if sort != "title" %}</a>{% endif%} /
            {% if sort != "pubdate" %}<a href="?sort=pubdate&start={{start}}&name={{name}}">{% endif %}出版{% if sort != "pubdate" %}</a>{% endif%} /
            {% if sort != "rating" %}<a href="?sort=rating&start={{start}}&name={{name}}">{% endif %}評分{% if sort != "rating" %}</a>{% endif%} /
            {% if sort != "timestamp" %}<a href="?sort=timestamp&start={{start}}&name={{name}}">{% endif %}更新{% if sort != "timestamp" %}</a>{% endif%}
        </div>
</span>

{% for book in books %}
    <div class="media list-book">
        <a class="pull-left" href="/book/{{book.id}}"><img class="lazy list-book-img media-object" data-original="{{IMG}}/get/cover/{{book.id}}.jpg?t={{book.timestamp}}" ></a>
        <div class="media-body">
            <h4 class="media-heading"><a href="/book/{{book.id}}">{{book.title}}</a></h4>
            <p>
                <a href="/author/{{book.author_sort|urlencode}}">{{book.authors|join(", ")}}</a> /
                <a href="/pub/{{book.publisher|urlencode}}">{{book.publisher}}</a> /
                {{book.pubdate|day}} /
                {%if book.count_download%}{{book.count_download}}{%else%}0{%endif%} 次下載
                <br/>
                <span class="brief">{% if book.comments %}{{book.comments|striptags}}{%endif%}</span>
            </p>
        </div>
    </div>
{% endfor %}

<ul class="pagination">
    <li {% if page_now == 0 %}class="disabled"{%endif%}><a href="?sort={{sort}}&start={{page_now*delta-delta}}&name={{name}}">&laquo; 前頁</a></li>

    {% for p in pages %}
    <li {%if page_now == p %}class="active"{%endif%}><a href="?sort={{sort}}&start={{p*delta}}&name={{name}}">{{p+1}}</a></li>
    {% endfor %}

    {% if page_max not in pages %}
    <li class="disabled"><a href="#">...</a></li>
    <li><a href="?sort={{sort}}&start={{page_max*delta}}&name={{name}}">{{page_max+1}}</a></li>
    {% endif %}

    <li {% if page_now == page_max %}class="disabled"{%endif%}><a href="?sort={{sort}}&start={{page_now*delta+delta}}&name={{name}}">後頁 &raquo;</a></li>
</ul>
{% endblock %}

{% block sidebar %}
{% include "sidebar/basic.html" %}
{% endblock %}
